package com.android.volley.toolbox;

import android.graphics.Bitmap;
import android.util.LruCache;

import com.android.volley.toolbox.ImageLoader;

/**
 * Created by chshqiang on 14-3-12.
 * 图片缓存
 */
public class BitmapImageCache implements ImageLoader.ImageCache {
    private LruCache<String, Bitmap> cache;

    public BitmapImageCache() {
        cache = new LruCache<String, Bitmap>(8 * 1024 * 1024);
    }

    public BitmapImageCache(int max) {
        cache = new LruCache<String, Bitmap>(max);
    }

    @Override
    public Bitmap getBitmap(String url) {
        return cache.get(url);
    }

    @Override
    public void putBitmap(String url, Bitmap bitmap) {
        cache.put(url, bitmap);
    }
}
